<template>
	<view>
		<view class="body" style=" max-width:640px; overflow:auto; overflow-x:hidden">
			<!--header-->
			<dfHeader :type="type" :key="timer"></dfHeader>
			<div class='content1 grey'>
				<section class="index_st15">
					<div class="cont_tit">{{data.title}}</div>
					<div class="ydl">
						<div class="dj"> 阅读:{{data.hits}}</div>
						<div class="time">{{data.time}}</div>
					</div>
					<div class="all">
						<div class="pic"></div>
						<div class="yuedu">
							<video id="myVideo" width="80%" :src="config.staticUrl+data.video" controls :poster="data.pic" :autoplay='true'
							 :loop="true"></video>
						</div>
					</div>
				</section>
				<dfFooter></dfFooter>
			</div>
		</view>
		<df-form :showIcon="true" :open="openFormStatus"></df-form>
	</view>
</template>

<script>
	import dfForm from '@/pages/common/form.vue';
	// 处理html字符串
	import htmlParser from '@/common/html-parser'	
	export default {

		components: {
			dfForm
		},
		data() {
			return {
				config: this.$config,
				timer: '',
				type: 0,
				openFormStatus: false,
				loading: true,
				data: {},
				htmlNodes: ''
			}
		},
		onLoad(event) {
			var id = this.$Route.query.id.replace(".html", '');
			console.log(this.$Route.query)
			this.data.id = id;
			this.getDetail();
		},
		onBackPress() {
			this.$functions.setSubs(this.$config.subs)
		},
		methods: {
			// 打开加盟框
			openForm() {
				// 轮流切换open值，触发模板里的watch函数
				this.openFormStatus = this.openFormStatus ? false : true;
				console.log('openForm');
			},
			getDetail() {
				let _this = this;
				this.$request.api_request('pl_list_detail', {
					id: this.data.id
				}).then(function(data) {
					// console.log(data)
					data = data.result;
					// 页面容错
					if (data.title == undefined) {
						_this.$functions.goPage("/404");
					}
					_this.type = data.typeId;
					// 触发header刷新，用来将文章定位到菜单
					_this.timer = new Date().getTime();
					data.pic = _this.$config.staticUrl + data.pic;
					_this.data = data;
					_this.$functions.setTDK(data.title, data.subs, data.keywords);
					// 去掉图片，不然会影响文本显示
					var htmlString = data.content.replace(/\\/g, "").replace(/<img/g, "<img style=\"display:none !important;\"");
					_this.htmlNodes = htmlParser(htmlString);
					_this.loading = false;
				})
			},
		}
	}
</script>
<style>
	video {
		width: 100% !important;
	}
</style>
